<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
	<%@page import="com.Dao.SubDao"%>
<%@page import="com.pojo.Sub"%>
	<%@page import="com.Dao.ProcDao"%>
<%@page import="com.pojo.Sight"%>
<%@page import="com.pojo.User" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>HI视角| HI社区</title>
<link href="bootstrap.css" rel="stylesheet">
<script src="jquery.js"></script>
<script src="bootstrap.js"></script>
<link href="summernote.css" rel="stylesheet">
 <script type="text/javascript" charset="utf-8" src="ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="ueditor/ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="ueditor/lang/zh-cn/zh-cn.js"></script>
<script src="summernote.js"></script>

<link rel="stylesheet" type="text/css"
	href="./HI-files/css/candy-box.css">
<link rel="stylesheet" type="text/css"
	href="./HI-files/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css"
	href="./HI-files/css/animate.min.css">
<link rel="stylesheet" type="text/css"
	href="./HI-files/css/jquery.skippr.css">
<link rel="stylesheet" type="text/css" href="./HI-files/css/style.css">

</head>


<body style="">

	<%@ include file="./include/header.jsp"%>
	<%
			String SId = request.getParameter("SId");
			SubDao SubDao = new SubDao();
			Sub Sub = SubDao.findcards(SId);
			User User =SubDao.findname(SId); 
	%>
	<%String address ="./text.jsp?SId="+SId;
session.setAttribute("address",address);%>
	<section class="view-header">
	<div class="container">
		<div class="row">
			<div class="col-sm-12">
				<ul class="breadcrumb">
					
					<li><a href="#"><%=Sub.getTheme() %></a></li>
					<li class="active">内容</li>
				</ul>

			</div>
		</div>
	</div>
	</section>
	<section class="view-content-info">
	<div class="container">
		<div class="row">
			<div class="col-sm-9">
			
				<div class="view-content-left">
					<div class="content-header">
						<h2><%=Sub.getTitlel() %></h2>
						<span><a href="#"><img src="./HI-files/images/img1.jpg"
								style="float: left; height: 25px; width: 25px; border-radius: 50%; margin-right: 5px"><%=User.getUname() %></a>
							<i class="fa fa-clock-o"></i><%=Sub.getTime() %></span>
					</div>
					<p></p>
					<div id="myarticle" class="article"
						style="height: 150px; overflow-y: hidden;">
						<!-- 帖子内容 -->
						<%=Sub.getContant() %>
					
					</div>
					<span id="btn" style="width: 700px; margin: 10px auto; text-align: center; display: none; cursor: pointer;">点击显示更多……</span>

					<hr>
					<span class="pull-left">点赞：</span>
					<div class="clearfix"></div>
				</div>
				<!-- 评论列表 -->
				<div id="xinxi">
				<%
				
				ProcDao ProcDao = new ProcDao();
				Sight[] shopArrx = ProcDao.findAllGartx(SId);	
				for (int i = 0; i < ProcDao.getCount1(); i++) {
				%>
				<div class="view-content-left animated bounceIn" data-animation="bounceIn" data-delay="0" style="opacity: 0;">
						<span><%=shopArrx[i].getUname() %></span><span><%=shopArrx[i].getHuifu() %></span>
						<div style="font-size:8px;"><%=shopArrx[i].getTimes() %></div>
						</div>
				<%} %>
					</div>
				<div id="pl" class="pl" style="width:100%;height:40px;">
				
						<%Integer Uid = null;
						if((User)session.getAttribute("user")!= null){ 
							  Uid = ((User)session.getAttribute("user")).getUid();
					if(((User)session.getAttribute("user")).getUjst().equals("封禁账户")){%>
					<h3>账号已被封禁，禁止评论</h3>
					<%
						} 
					else{
					%>
					<div style="cursor:pointer;background:white;width:80px;height:40px;line-height:40px;text-align: center;margin-left: 768px;" onclick="pl()">
					我要评论
					</div>					
					<%
					   }
						}
						else{
						%>   
							<a href="./login/login.jsp">点击登录评论</a>	
						<%
						}
						%>
				</div>
				<!-- 富文本框 -->
				<div id ="futext" style="display:none;">
					<div>
					    <script id="editor" type="text/plain" style="width:100%;height:200px;"></script>
					</div>
					<div id="btns">
					    <div>		
					    	<button onclick="getClk2()">发表</button>			       
					       		
					    </div>
					</div>
				
					</div>


			</div>
			<div class="col-sm-3">
				<div class="view-content-right">
					
				</div>
				
				<div class="view-content-right" style="margin: 20px 0;">
					
				</div>

				
			</div>
		</div>
	</div>
	</section>

	<%@ include file="./include/footer.jsp"%>

	

<script type="text/javascript">
//实例化编辑器
//建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
var ue = UE.getEditor('editor');
function pl(){
	var pl= document.getElementById('pl');
	var futext= document.getElementById('futext');
	futext.style.display = 'block';
	pl.style.display = 'none';
}

function isFocus(e){
    alert(UE.getEditor('editor').isFocus());
    UE.dom.domUtils.preventDefault(e)
}
function setblur(e){
    UE.getEditor('editor').blur();
    UE.dom.domUtils.preventDefault(e)
}
function insertHtml() {
    var value = prompt('插入html代码', '');
    UE.getEditor('editor').execCommand('insertHtml', value)
}
function createEditor() {
    enableBtn();
    UE.getEditor('editor');
}
function getAllHtml() {
    alert(UE.getEditor('editor').getAllHtml())
}
function getContent() {
    var arr = [];
    arr.push("使用editor.getContent()方法可以获得编辑器的内容");
    arr.push("内容为：");
    arr.push(UE.getEditor('editor').getContent());
    alert(arr.join("\n"));
}
function getPlainTxt() {
    var arr = [];
    arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
    arr.push("内容为：");
    arr.push(UE.getEditor('editor').getPlainTxt());
    alert(arr.join('\n'))
}
function setContent(isAppendTo) {
    var arr = [];
    arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
    UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
    alert(arr.join("\n"));
}
function setDisabled() {
    UE.getEditor('editor').setDisabled('fullscreen');
    disableBtn("enable");
}

function setEnabled() {
    UE.getEditor('editor').setEnabled();
    enableBtn();
}

function getText() {
    //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
    var range = UE.getEditor('editor').selection.getRange();
    range.select();
    var txt = UE.getEditor('editor').selection.getText();
    alert(txt)
}

function getContentTxt() {
    var arr = [];
    arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
    arr.push("编辑器的纯文本内容为：");
    arr.push(UE.getEditor('editor').getContentTxt());
    alert(arr.join("\n"));
}
function hasContent() {
    var arr = [];
    arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
    arr.push("判断结果为：");
    arr.push(UE.getEditor('editor').hasContents());
    alert(arr.join("\n"));
}
function setFocus() {
    UE.getEditor('editor').focus();
}
function deleteEditor() {
    disableBtn();
    UE.getEditor('editor').destroy();
}
function disableBtn(str) {
    var div = document.getElementById('btns');
    var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
    for (var i = 0, btn; btn = btns[i++];) {
        if (btn.id == str) {
            UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
        } else {
            btn.setAttribute("disabled", "true");
        }
    }
}
function enableBtn() {
    var div = document.getElementById('btns');
    var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
    for (var i = 0, btn; btn = btns[i++];) {
        UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
    }
}

function getLocalData () {
    alert(UE.getEditor('editor').execCommand( "getlocaldata" ));
}

function clearLocalData () {
    UE.getEditor('editor').execCommand( "clearlocaldata" );
    alert("已清空草稿箱")
}
</script>

	<script>
		var btn = document.getElementById('btn');
		var obj = document.getElementById('myarticle');
		var total_height = obj.scrollHeight;//文章总高度
		var show_height = 100;//定义原始显示高度
		if (total_height > show_height) {
			btn.style.display = 'block';
			btn.onclick = function() {
				obj.style.height = total_height + 'px';
				btn.style.display = 'none';
			}

	}
		
		
	</script>
		<script type="text/javascript">
			function getClk2() {
				var datax = UE.getEditor('editor').getContent() ;
				var neirong = UE.getEditor('editor').hasContents();
				var Sid = null;
				var Uid = null;
				var use= <%= ((User)session.getAttribute("user")).getUphone() %>;
				if(use != null){
					 Sid = <%=Sub.getSId()%>;
					 Uid = <%= Uid %> ;
				}
				
				
				if (neirong){
				$.post("${pageContext.request.contextPath }/procCtr",
						{datax:datax,id:Sid,uid:Uid},
				    	function(data){

							var count =0
						for(var i=0;i<data.length;i++){
							var x = JSON.stringify(data[i]);
								if(x == "null"){
									count= i;
									break;
								}
							
							}
						var str ="";
						
						for(var i=0;i<count;i++){
							str+='<div class="view-content-left animated bounceIn" data-animation="bounceIn" data-delay="0" style="opacity: 0;">';
							str+='<span>'+data[i].Uname+'</span><span>'+data[i].huifu+'</span>';
							str+='<div style="font-size:8px;">'+data[i].times+'</div>';
							str+='</div>';	
							
							}
						document.getElementById('xinxi').innerHTML=str;	
								
				        },"json"
				);
				}else{
					alert('请输入内容');
				};
			};
					    
					</script>
</body>
</html>